package com.shuw.com.beingfortextproject.adapter;

import android.support.v4.view.PagerAdapter;
import android.view.View;
import android.view.ViewGroup;

import java.util.List;

/**
 * Created by ${cs} on 2018/4/28.
 */

public class ViewPagerAdapter  extends PagerAdapter {

	private List<View> mViewList;

	public ViewPagerAdapter(List<View> viewList) {
		this.mViewList = viewList;
	}

	@Override
	public int getCount() {
		return mViewList == null?0:mViewList.size();
	}

	@Override
	public boolean isViewFromObject(View view, Object object) {//丶丶丶丶丶
		return view == object;
	}

	@Override
	public Object instantiateItem(ViewGroup container, int position) {
		container.addView(mViewList.get(position));
		return mViewList.get(position);
	}

	@Override
	public void destroyItem(ViewGroup container, int position, Object object) {
		container.removeView(mViewList.get(position));
	}
}
